package Controller;

import Pojo.Order;
import Service.impl.OrderServiceImpl;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class OrderQueryByIdServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        try {
            String orderIdGet = request.getParameter("orderIdGet");
            OrderServiceImpl orderService=new OrderServiceImpl();
            Order order=orderService.OrderQueryById(Integer.parseInt(orderIdGet));
            System.out.println(order.toString());
            response.getWriter().print(JSON.toJSONString(order));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
